<?php
  require_once('template.php');
  $sTemplateFolderPath = './templates/';
  
  $oTpl = & new Template($sTemplateFolderPath, 'layout.svg.php'); // this is the outer template
  $oTpl->set('sTitle', 'Malware Aquarium');
  
  // TODO: more fish from the directory
  $aFish = array(
	  	"fish/mystica_Aquarium_fish_-_Cirrhilabrus_jordani.svg",
		
	  );
  
  $oTpl->set('aFish', $aFish);
  $aData =  getCSV('fish.csv');
  //var_dump($aData);
  $oTpl->set('aData', $aData);
  
  echo $oTpl->fetch();
  
  
  function getCSV($sFile)
  {
	$row = 1;
	$handle = fopen($sFile, "r");
	$aData = array();
	$aNames = fgetcsv($handle, 1000, ",");
	while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
		//$aData[] = $data;
	    $num = count($data);
	    $row++;
	    $aDataLine = array();
	    for ($c=0; $c < $num; $c++) {
		$aDataLine[$aNames[$c]] = $data[$c];
	    }
	    $aData[] = $aDataLine;
	}
	fclose($handle);
	return $aData;
  }
